import React from 'react';
import { withRouter, Link } from 'react-router-dom';
// import { setUserRole } from 'pages/app/action';
import http from 'libs/http';

import './index.less';
import logoPic from 'images/logo.png';

class StudentHeader extends React.Component {
  constructor(props) {
    super(props)
  }

  handleLogout = () => {
    // http.post({
    //   url: '/student/logOut',
    //   data: {},
    //   success: res => {
    //     this.props.history.push('/home');
    //   }
    // })
    http.post('student/logOut').then(res => {
      this.props.history.push('/home')
    })
  }

  render () {
    return (
      <header className="student-header">
        <div className="header-top">
          <Link to="/home"><img className="student-logo" src={logoPic} /></Link>
          <div className="logout" onClick={this.handleLogout}>
            <span>退出</span>
          </div>
        </div>
        <div className="header-main">
          <h1 className="title-cn">改变世界，从学习开始</h1>
          <h3 className="title-en">CHANGE THE WORLD, LEARN FIRST!</h3>
        </div>
      </header>
    );
  }
}

export default withRouter(StudentHeader)
